package com.itheima.controller;

import com.itheima.pojo.Dept;
import com.itheima.pojo.Result;
import com.itheima.service.impl.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController

public class DeptController {
    @Autowired
    private DeptService deptService;
    //@RequestMapping(value = "/depts",method = RequestMethod.GET)//指定请求方式为get
    @GetMapping("/depts")//相当于上面
    public Result list(){
        log.info("查询全部部门数据");
        //调用service查询全部数据
        List<Dept> deptList=deptService.list();
        return Result.success(deptList);
    }
}